import { proxy } from 'valtio';
import { get, post } from "../request"
interface DataType {
    key: string;
    brand?: string;
    platform?: string;
    partition?: string;
    shop?: string;
    name: string;
    type: string;
    price: number;
    nums: number;
    sum: number;
    date: string;
    children?: DataType[];
}
export const Finance3 = proxy({
    data:[] as DataType[],
    brand:"",
    partition:"",
    shop:"",
    platform:"",
    date:"",
    today:"",
    getArgs:(brand:string,partition:string,shop:string,platform:string,date:string,today:string)=>{
        Finance3.brand = brand
        Finance3.partition = partition
        Finance3.shop = shop
        Finance3.platform = platform
        Finance3.date = date
        Finance3.today = today
    },
    getList: () => {
        get("/revenue").then((res: any) => {
            Finance3.data = res.data as DataType[]
        })
    },
    search:()=>{
        post("/revenue/search",{
            brand:Finance3.brand,
            partition:Finance3.partition,
            shop:Finance3.shop,
            platform:Finance3.platform,
            date:Finance3.date,
            today:Finance3.today
        }).then((res: any)=>{
            Finance3.data = res.data as DataType[]
        })
    }
})